package com.wysql.ascost.controller.info;

import com.github.pagehelper.PageInfo;
import com.wysql.ascost.common.base.BaseController;
import com.wysql.ascost.common.domain.AjaxResult;
import com.wysql.ascost.common.domain.ResultTable;
import com.wysql.ascost.model.custom.Tablepar;
import com.wysql.ascost.model.info.InfoImportresult;
import com.wysql.ascost.service.info.InfoImportresultService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

/**
 * 导入操作台账Controller
 * @ClassName: InfoImportresultController
 * @author wysqlauto
 * @date 2025-02-25 10:51:34
 */
@Api(value = "导入操作台账")
@Controller
@RequestMapping("/InfoImportresultController")
public class InfoImportresultController extends BaseController {

    private String prefix = "info/infoImportresult";

    @Autowired
    private InfoImportresultService infoImportresultService;


    /**
     * 导入操作台账页面展示
     * @param model
     * @return String
     * @author wysqlauto
     */
    @ApiOperation(value = "分页跳转", notes = "分页跳转")
    @GetMapping("/view")
    @RequiresPermissions("info:infoImportresult:view")
    public String view(ModelMap model) {
        return prefix + "/list";
    }

    /**
     * list集合
     * @param tablepar
     * @param
     * @return
     */
    //@Log(title = "导入操作台账", action = "111")
    @ApiOperation(value = "分页跳转", notes = "分页跳转")
    @GetMapping("/list")
    @RequiresPermissions("info:infoImportresult:list")
    @ResponseBody
    public ResultTable list(Tablepar tablepar, InfoImportresult infoImportresult) {
        PageInfo<InfoImportresult> page = infoImportresultService.list(tablepar,infoImportresult);
        return pageTable(page.getList(), page.getTotal());
    }

    /**
     * 新增跳转
     */
    @ApiOperation(value = "新增跳转", notes = "新增跳转")
    @GetMapping("/add")
    public String add(ModelMap modelMap) {
        return prefix + "/add";
    }

    /**
     * 新增保存
     * @param 
     * @return
     */
    //@Log(title = "导入操作台账新增", action = "111")
    @ApiOperation(value = "新增", notes = "新增")
    @PostMapping("/add")
    @RequiresPermissions("info:infoImportresult:add")
    @ResponseBody
    public AjaxResult add(InfoImportresult infoImportresult) {
        int b = infoImportresultService.insertSelective(infoImportresult);
        if (b > 0) {
            return success();
        } else {
            return error();
        }
    }

    /**
     * 导入操作台账删除
     * @param ids
     * @return
     */
    //@Log(title = "导入操作台账删除", action = "111")
    @ApiOperation(value = "删除", notes = "删除")
    @DeleteMapping("/remove")
    @RequiresPermissions("info:infoImportresult:remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        int b = infoImportresultService.deleteByPrimaryKey(ids);
        if (b > 0) {
            return success();
        } else {
            return error();
        }
    }


    /**
     * 修改跳转
     * @param id
     * @param
     * @return
     */
    @ApiOperation(value = "修改跳转", notes = "修改跳转")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap map) {
        map.put("InfoImportresult", infoImportresultService.selectByPrimaryKey(id));

        return prefix + "/edit";
    }

    /**
     * 修改保存
     */
    //@Log(title = "导入操作台账修改", action = "111")
    @ApiOperation(value = "修改保存", notes = "修改保存")
    @RequiresPermissions("info:infoImportresult:edit")
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(InfoImportresult infoImportresult) {
        return toAjax(infoImportresultService.updateByPrimaryKeySelective(infoImportresult));
    }

    /**
     * 单行上按钮查看导入操作详情页面跳转
     * @param model
     * @return String
     * @author wysqlauto
     */
    @ApiOperation(value = "单行上按钮查看导入操作详情页面跳转", notes = "单行上按钮查看导入操作详情页面跳转")
    @GetMapping("/finddtl/{id}")
    public String finddtl(@PathVariable("id") String id, ModelMap model) {
        model.addAttribute("mainid",id.toString());
        return prefix + "/finddtl";
    }

}
